<?php

namespace easydis\APSBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;

/**
 * Poste
 *
 * @ORM\Table()
 * @ORM\Entity(repositoryClass="easydis\APSBundle\EntityRepository\PosteRepository")
 */
class Poste
{
    /**
     * @var integer
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;

    /**
     * @var string
     *
     * @ORM\Column(name="lib", type="string", length=100)
     */
    private $lib;
    
    /**
     * @var string
     *
     * @ORM\Column(name="color", type="string", length=10, nullable=false)
     */
    private $color;
    
    /**
     * @ORM\ManyToOne(targetEntity="easydis\APSBundle\Entity\Section")
     * @ORM\JoinColumn(nullable=false)
     */
    private $section;
    
    /**
     * @var ArrayCollection $children
     * 
     * @ORM\OneToMany(targetEntity="easydis\APSBundle\Entity\Planifier", mappedBy="poste", cascade={"remove"})
     */
    private $children;
    
    /**
     * @var boolean
     *
     * @ORM\Column(name="visibilite", type="boolean", length=2)
     */
    private $visibilite = true;
    
    /**
     * @var integer
     *
     * @ORM\Column(name="ordre", type="integer", length=4)
     */
    private $ordre = 1;
    
    public function __construct() {
        $this->children = new ArrayCollection();
        $this->color = '#000';
    }   
    
    public function setAll($lib, $section) {
        $this->lib = str_replace('/', '+',$lib);
        $this->section = $section;
    }
    
     /**
     * @param easydis\APSBundle\Entity\Planifier $planif
     */
    public function addChildren($planif) {
        // Si l'objet fait déjà partie de la collection on ne l'ajoute pas
        if (!$this->children->contains($planif)) {
            $this->children->add($planif);
        }
    }
 
    /**
     * @return ArrayCollection $children
     */
    public function getChildren() {
        return $this->children;
    }
    
    /**
      * Set section
      *
      * @param easydis\APSBundle\Entity\Section $section
      */
    public function setSection(\easydis\APSBundle\Entity\Section $section)
    {
            $this->section = $section;
    }

    /**
      * Get section
      *
      * @return easydis\APSBundle\Entity\Section 
      */
    public function getSection()
    {
            return $this->section;
    }
    
    /**
     * Set lib
     *
     * @param string $lib
     * @return TypeContrat
     */
    public function setLib($lib)
    {
        $this->lib = str_replace('/', '+',$lib);
    
        return $this;
    }

    /**
     * Get lib
     *
     * @return string 
     */
    public function getLib()
    {
        return $this->lib;
    }
    
    /**
     * Set color
     *
     * @param string $color
     * @return TypeContrat
     */
    public function setColor($color)
    {
        $this->color = $color;
    
        return $this;
    }

    /**
     * Get color
     *
     * @return string 
     */
    public function getColor()
    {
        return $this->color;
    }
    
    
    /**
     * Get id
     *
     * @return integer 
     */
    public function getId()
    {
        return $this->id;
    }
    
    /**
     * Set id
     *
     * @param interger $id
     * @return PlageHoraire
     */
    public function setId($id)
    {
        $this->id = $id;
    
        return $this;
    }
    
    /**
     * Get visibilite
     *
     * @return boolean 
     */
    public function getVisibilite()
    {
        return $this->visibilite;
    }
    
    /**
     * Set visibilite
     *
     * @param boolean $visibilite
     */
    public function setVisibilite($visibilite)
    {
        $this->visibilite = $visibilite;
    }
    
    /**
     * Get ordre
     *
     * @return integer 
     */
    public function getOrdre()
    {
        return $this->ordre;
    }
    
    /**
     * Set ordre
     *
     * @param interger $ordre
     * @return PlageHoraire
     */
    public function setOrdre($ordre)
    {
        $this->ordre = $ordre;
    
        return $this;
    }
}
